<template>
	<view class="wrap">
		<view class="inner">
			<view class="banner" @click="enterpage(oneData)">
				<image class="banner-bg" :src="oneData.cover" mode=""></image>
				<view class="content">
					<view class="item">
						{{oneData.title}}
			
					</view>
					
				</view>
			</view>
			
			
			<view @click="enterpage(item)" class="p-list" v-for="(item,index) in pList" :key="index">
				<view class="left">
					{{item.title}}
				</view>
				<view class="right">
					<image :src="item.cover" mode=""></image>
				</view>
			</view>
		</view>
		<uni-load-more  :status="more">
		</uni-load-more>
	</view>
</template>

<script>
	
	function parseQueryString(url){
		if(url.split("?").length==1){
			return {
				urls:url
			}
		}
	      var str=url.split("?")[1];
	       var iterms = str.split("&");
	       var arr,Json={};
	       for(var i=0;i<iterms.length;i++){
	               arr=iterms[i].split("=");
	               Json[arr[0]]=arr[1];
	       }
		   Json.urls=url.split("?")[0]
	       return Json;
	}
	export default {
		data() {
			return {
				more:'loading',
				nowpage:1,
				oneData:{},
				pList:[]
			}
		},
		onPullDownRefresh:function(){
			this.more='more'
			this.dataObj=[]
			this.nowpage=1
			this.getData()
		 },
		onReachBottom() {
			if(this.more=='nomore'){
				return
			}
			this.getData()	
		},
		onShow() {
			//this.getData()
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData(){
				let that=this
				that.apipost('/api/home/info',{page:that.nowpage},true).then(res => {
					if(res.Code==10200){
						
						let data=res.Data
						
						that.pList=that.pList.concat(data)
						++that.nowpage
						uni.stopPullDownRefresh()
						if(data.length<15){
							that.more='nomore'
						}
						that.oneData=that.pList[0]
						//that.pList=that.pList.slice(1,that.pList)
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			enterpage(item){
				let urlPas=parseQueryString(item.url)
				let stringUrl='lk=12'
				for(let items in urlPas){
					stringUrl+='&'+items+'='+urlPas[items]
				}
				uni.navigateTo({
				    url: `../hangyezixundetail/index?${stringUrl}`
				});
				
			}
		}
	}
</script>

<style>
	.p-list:last-child
	{ 
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
	}
	.p-list .right{
		position:relative;
		top:-10rpx;
		width:104rpx;
		height:104rpx;
		margin-left:30rpx;
	}
	.p-list .left{
		padding-bottom:44rpx;
		border-bottom:1rpx solid #d4d4d4;
		flex:1;
	}
	.p-list{
		align-items: center;
		display:flex;
		/* padding:18rpx 28rpx  14rpx 38rpx; */
		padding:0rpx 28rpx 0rpx 38rpx;
		background:#fff;
		height:152rpx;
		box-sizing: border-box;
		
	}
	.banner .item{
		padding-left:36rpx;
		padding-bottom:18rpx;
		color:#fff;
		font-size:34rpx;
		font-weight:bold;
	}
	.banner .content{
		position:absolute;
		bottom:6rpx;
	}
	.wrap{
		width:692rpx;
		margin:10rpx auto 10rpx auto;
		padding-bottom:10rpx;
		box-shadow: 0px 0px 4px  #a8a1a1;
		border-radius: 20rpx;
	}
	.banner-bg{
		height:338rpx;
	}
	.banner{
		position:relative;
		height:338rpx;
		
	}
	.banner uni-image{
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
	}
</style>
